﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;

namespace GaraOto
{
    public partial class frmMain : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public frmMain()
        {
            InitializeComponent();
            xtraTabAddStaff.Controls.Clear();
            frmAddStaff frm = new frmAddStaff();
            xtraTabAddStaff.Controls.Add(frm);
            frm.Dock = DockStyle.Fill;
        }

        private void bbtnAddStaff_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (xtcHome.TabPages.Contains(xtraTabAddStaff))
            {
                if (xtcHome.SelectedTabPage != xtraTabAddStaff)
                {
                    xtcHome.SelectedTabPage = xtraTabAddStaff;
                }
            }
            else
            {
                xtcHome.TabPages.Add(xtraTabAddStaff);
                //xtcHome.TabPages.Add(xtraTabAddStaff);
                xtraTabAddStaff.Controls.Clear();
                frmAddStaff frm = new frmAddStaff();
                xtraTabAddStaff.Controls.Add(frm);
                frm.Dock = DockStyle.Fill;

                xtcHome.SelectedTabPage = xtraTabAddStaff;
            }            
        }
        

        private void frmMain_Load(object sender, EventArgs e)
        {
            //tat bo tat ca  cac tab
            while (xtcHome.TabPages.Count != 0)
            {
                for (int i = 0; i < xtcHome.TabPages.Count; i++)
                {
                    xtcHome.TabPages.RemoveAt(i);
                }
            }
        }

        private void xtcHome_CloseButtonClick(object sender, EventArgs e)
        {
            xtcHome.TabPages.RemoveAt(xtcHome.SelectedTabPageIndex);
        }

        public void bbtnAddCustomer_ItemClick(object sender, ItemClickEventArgs e)
        {
            bbtnAddCustomer_Click();
        }

        public void bbtnAddCustomer_Click()
        {
            if (xtcHome.TabPages.Contains(xtraTabAddCustomer))
            {
                if (xtcHome.SelectedTabPage != xtraTabAddCustomer)
                {
                    xtcHome.SelectedTabPage = xtraTabAddCustomer;
                }
            }
            else
            {
                xtcHome.TabPages.Add(xtraTabAddCustomer);
                xtraTabAddCustomer.Controls.Clear();
                frmCustomerManager frm = new frmCustomerManager();
                xtraTabAddCustomer.Controls.Add(frm);
                frm.Dock = DockStyle.Fill;

                xtcHome.SelectedTabPage = xtraTabAddCustomer;
            }
        }

        private void bbtnCardManager_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (xtcHome.TabPages.Contains(xtraTabCardManager))
            {
                if (xtcHome.SelectedTabPage != xtraTabCardManager)
                {
                    xtcHome.SelectedTabPage = xtraTabCardManager;
                }
            }
            else
            {
                xtcHome.TabPages.Add(xtraTabCardManager);
                xtraTabCardManager.Controls.Clear();
                frmCardManager frm = new frmCardManager();
                xtraTabCardManager.Controls.Add(frm);
                frm.Dock = DockStyle.Fill;

                xtcHome.SelectedTabPage = xtraTabCardManager;
            }
        }

        private void bbtnLotManager_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (xtcHome.TabPages.Contains(xtraTabLotManager))
            {
                if (xtcHome.SelectedTabPage != xtraTabLotManager)
                {
                    xtcHome.SelectedTabPage = xtraTabLotManager;
                }
            }
            else
            {
                xtcHome.TabPages.Add(xtraTabLotManager);
                xtraTabLotManager.Controls.Clear();
                frmLotManager frm = new frmLotManager();
                xtraTabLotManager.Controls.Add(frm);
                frm.Dock = DockStyle.Fill;

                xtcHome.SelectedTabPage = xtraTabLotManager;
            }
        }

        private void barButtonItem2_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (xtcHome.TabPages.Contains(xtraTabAddCustomer))
            {
                if (xtcHome.SelectedTabPage != xtraTabAddCustomer)
                {
                    xtcHome.SelectedTabPage = xtraTabAddCustomer;
                }
            }
            else
            {
                xtcHome.TabPages.Add(xtraTabAddCustomer);
                xtraTabAddCustomer.Controls.Clear();
                frmCustomerManager frm = new frmCustomerManager();
                xtraTabAddCustomer.Controls.Add(frm);
                frm.Dock = DockStyle.Fill;

                xtcHome.SelectedTabPage = xtraTabAddCustomer;
            }
        }

        private void bbtnFeeManager_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (xtcHome.TabPages.Contains(xtraTabFeeManager))
            {
                if (xtcHome.SelectedTabPage != xtraTabFeeManager)
                {
                    xtcHome.SelectedTabPage = xtraTabFeeManager;
                }
            }
            else
            {
                xtcHome.TabPages.Add(xtraTabFeeManager);
                xtraTabFeeManager.Controls.Clear();
                frmFeeManager frm = new frmFeeManager();
                xtraTabFeeManager.Controls.Add(frm);
                frm.Dock = DockStyle.Fill;

                xtcHome.SelectedTabPage = xtraTabFeeManager;
            }
        }

        public void bbtnInputManager_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmInputManager frm = new frmInputManager();
            frm.Show(this);
        }

        
    }
}